package cn.com.zhangwoo.microstar.utildb;

import cn.com.microstar.activity.R;
import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
/**
 * 自定义Toast
 * 
 * @author chenglei
 *
 */
public class CommonToast {

	
	public static Toast showToast(Context context, CharSequence text, int duration) {
		Toast result = new Toast(context);
        LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflate.inflate(R.layout.common_toast_layout, null);
        TextView tv = (TextView) v.findViewById(R.id.common_toast_message);
        tv.setText(text);
		result.setView(v);
        result.setDuration(duration);
        result.show();
        return result;

	}
	
	public static Toast showToast(Context context, int resId, int duration) throws Resources.NotFoundException {
		return showToast(context, context.getResources().getText(resId), duration);
	}
	
	
	public static void showToastException(Context context, CharSequence text, int duration) {
		 Toast.makeText(context, text, duration).show();
	}

}
